﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

namespace NCKH
{
    public partial class Icandoit : System.Web.UI.Page
    {
        
        public int count;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("ID");
                dt.Columns.Add("name");

                DataRow dr = dt.NewRow();

                dr["ID"] = 1;
                dr["Name"] = "hello";

                dt.Rows.Add(dr);

                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
        }
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "test")
            {

                int RowIndex = int.Parse(e.CommandArgument.ToString().Trim());

                DropDownList ddtest = (DropDownList)GridView1.Rows[RowIndex].FindControl("dd1");

                //string abc = ddtest.SelectedValue;
                string abc = ddtest.SelectedItem.Text;
                lbl.Text = "bạn vừa chọn" + abc;
            }
        }
       protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {

                //DataRowView oRow = (DataRowView)e.Row.DataItem;

                LinkButton lnkPostType = (LinkButton)e.Row.FindControl("linkbpostype");

                lnkPostType.CommandArgument = count.ToString();

                count++;

            }
        }
    }
}